package com.fsy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fsy.entities.Roles;
import com.fsy.service.RolesService;
import com.fsy.mapper.RolesMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 凡凡
* @description 针对表【roles】的数据库操作Service实现
* @createDate 2022-04-17 20:38:33
*/
@Service
public class RolesServiceImpl extends ServiceImpl<RolesMapper, Roles>
    implements RolesService{

    @Resource
    private RolesMapper rolesMapper;

    /**
     * 查询所有角色
     * @param roles
     * @return
     */
    public List<Roles> selectRolesById(Roles roles){
        int page = roles.getPage();
        int limit = roles.getLimit();
        int offset = (page-1)*limit;
        roles.setPage((page-1)*limit);
        roles.setOffset(offset);//计算偏移量
        return rolesMapper.selectRolesById(roles);
    }

    /**
     * 查询总数
     * @param roles
     * @return
     */
    public int selectCounts(Roles roles){
        return rolesMapper.selectCounts(roles);
    }

}




